﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using iOak.Business.Users;
using iOak.Business.Authentication;
using iOak.Domain.Users;

namespace iOak.Web
{
    public class WorkAssistant
    {
        private const string CookieName = "Oak.UserCookie";
        private HttpContextBase _httpContext = null;
        private UserService _userService = null;
        private FormsAuthenticationService _authenticationService = null;

        public WorkAssistant()
        {
            _httpContext = new HttpContextWrapper(HttpContext.Current) as HttpContextBase;
            _userService = new UserService();
            _authenticationService = new FormsAuthenticationService();
        }

        protected User GetCurrentUser()
        {
            
            User user = null;

            if (_httpContext != null)
            {
                if (user == null)
                {
                    user = _authenticationService.GetAuthenticatedUser();
                }
               
            }
            return user;
        }

        public User CurrentUser
        {
            get
            {
                return GetCurrentUser();
            }           
        }
    }
}